/*
 * Copyright 2014 Rivaldo.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hiva.gmovie.connection;

import com.hiva.gmovie.domain.MovieTheater;
import com.hiva.gmovie.reader.MovieTheaterReader;
import com.hiva.gmovie.util.Constants;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import net.htmlparser.jericho.Source;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sun.awt.windows.ThemeReader;

/**
 * Utility class to access and read a google movie url.
 * @author Rivaldo
 */
public class GMovieReader {
    
    private static final Logger LOG = LoggerFactory.getLogger(GMovieReader.class);

    public List<MovieTheater> readMovieTheaterPage() {
        
        Source source = null;
        List<MovieTheater> theater = new ArrayList<MovieTheater>();
        
        try {
            source = new Source(new URL(Constants.BASE_URL));
            
            MovieTheaterReader reader = new MovieTheaterReader();
            theater = reader.getMovieTheater(source);
            
        } catch (IOException ex) {
            LOG.error("URL access error.", ex);
        }
        
        return theater;
    }
    
}
